/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nexus.adec;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

/**
 *
 * @author rodrigo
 */
public class Coneccion {
    
    private Properties pro = new Properties();
    private String driver = "org.postgresql.Driver";
    private String url = "jdbc:postgresql://127.0.0.1/tisfcyt";
    //private String url = "jdbc:postgresql://192.168.2.16";
    private String username = "postgres";
    //private String username = "nexus";
    private String password = "admin";
    //private String password = ".nexus.";
    
    private Connection connection;
    private static Coneccion instance;
    
    private Coneccion(){
        /*try{
            URL url = ClassLoader.getSystemResource("");
            pro.load(url.openStream());
        }catch(Exception ex){
            ex.printStackTrace();
            System.err.println("No Existe el Properties");
        }*/
    }
    
    public Connection getConnection()throws Exception{
        if(connection==null || connection.isClosed()){
            Class.forName(driver);
            connection = DriverManager.getConnection(url, username, password);
        }
        return connection;
    }
    
    public static Coneccion getInstance(){
        if(instance == null) instance = new Coneccion();
        return instance;
    }
}
